package com.qfedu.aunt.commons.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qfedu.aunt.commons.pojo.Agent;
import com.qfedu.aunt.commons.result.R;
import com.qfedu.aunt.commons.service.AgentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 经纪人表 前端控制器
 * </p>
 *
 * @author xiaobobo
 * @since 2022-10-26
 */
@RestController
@RequestMapping("/aunt/commons/agent")
@Api(description = "经纪人模块",tags = "经纪人模块")
public class AgentController {


    @Autowired
    private AgentService agentService;


    /**
     * 通过城市名字分页获取经纪人信息
     * @param cityName
     * @param currentPage
     * @param pageSize
     * @return
     */
    @ApiOperation(value = "通过城市名字分页获取经纪人信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityName",value = "城市名字",dataType = "string",paramType = "path",required = true),
            @ApiImplicitParam(name = "currentPage",value = "当前页码",dataType = "int",paramType = "path",required = true),
            @ApiImplicitParam(name = "pageSize",value = "数据条目数",dataType = "int",paramType = "path",required = true),
            @ApiImplicitParam(name = "token",value = "用户身份标识",dataType = "string",paramType = "header",required = true)
    })
    @GetMapping("/findAgentByCityNameAndPage/{cityName}/{currentPage}/{pageSize}")
    public R findAgentByCityNameAndPage(
            @PathVariable("cityName") String cityName,
            @PathVariable("currentPage")  Integer currentPage,
            @PathVariable("pageSize") Integer pageSize){
            IPage<Agent> agentIPage=agentService.findAgentByCityNameAndPage(cityName,currentPage,pageSize);
            return R.ok().setData("agentList",agentIPage.getRecords()).setData("total",agentIPage.getTotal());
    }

}

